/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.isd.facturacion.rn;

import java.util.List;
import com.isd.global.modelo.CorreoElectronico;
import com.isd.global.web.MailFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;

/**
 *
 * @author Claudio
 */
public class GeneradorCatalogo extends Thread{

    @EJB MailFactory mailFactoryBean;
    List<CorreoElectronico> listaCorreos;

    public GeneradorCatalogo(MailFactory mailFactoryBean,List<CorreoElectronico> listaCorreos ) {
        this.mailFactoryBean = mailFactoryBean;
        this.listaCorreos = listaCorreos;
    }

    @Override
    public void run() {

        try {

            if(listaCorreos==null) return;
            if(listaCorreos.isEmpty()){                
                return;
            }
            mailFactoryBean.enviarCorreosElectronicos(listaCorreos);

        } catch (Exception e) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "run", e);            
        }
    }
}
